<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 长按键入 -->
    <script>
      var isLongPressedName = function (name, typed) {
        let j = 0
        for (let i = 0; i < typed.length; i++) {
          if (j < name.length && typed[i] === name[j]) {
            j++
          } else {
            if (i > 0 && typed[i] === typed[i - 1]) {
              continue
            } else {
              return false
            }
          }
        }
        return j === name.length
      }
      // console.log(isLongPressedName('alex', (typed = 'aaleex')))
      console.log(isLongPressedName('saeed', (typed = 'ssaaedd')))
    </script>
  </body>
</html>
